<template>
  <div>
    <h4 class="text-center">员工薪资明细</h4>
    <table class="table table-bordered table-striped table-hover">
      <thead>
      <tr class = "table">
        <th>工号</th>
        <th>姓名</th>
        <th>职位</th>
        <th>员工所属部门</th>
        <th>应发工资</th>
        <th>扣除工资小时数</th>
        <th>实发工资</th>
      </tr>
      </thead>
      <tbody>
      <tr v-for="item in userlist" :key="item.id">
        <td>{{ item.e_ID }}</td>
        <td>{{ item.e_NAME }}</td>
        <td>{{ joblist[item.e_JOB] }}</td>
        <td>{{ item.e_DEPARTMENT }}</td>
        <td>{{ (item.e_JOB+1)*3000 }}</td>
        <td>{{ item.e_ABSHOUR }}</td>
        <td>{{((item.e_JOB+1)*3000)-(item.e_ABSHOUR*5)}}</td>
      </tr>
      </tbody>
    </table>
  </div>
</template>


<script>
import axios from 'axios'
export default {
  name: 'MyGoods',
  data(){
    return{
      userlist: [],
      joblist: [
        '员工', '部门经理', '人事部职员', '总经理'
      ]
    }
  },
  mounted() {
    this.fetchdata();
  },
  methods: {
    //获取后端数据
    fetchdata() {
      axios.get('/api/personnel/report').then(res => {
        console.log(res.data);
        this.userlist = res.data.data;
      }).catch(err => {
        console.log(err.message)
      })
    }
  }
}
</script>

<style lang="less" scoped>
.table{
  background-color: white;
  text-align:center;
}
</style>